package cn.hnu.jpa.jpaExample.ManyToOne.SingleWay;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.junit.Test;

import cn.hnu.jpa.jpaExample.OneToMany.SingleWay.ModelAddr;
import cn.hnu.jpa.jpaExample.OneToMany.SingleWay.TableCustomer;


public class ManyToOneUnitTest {

	//@Test
	public void test() {
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa");
		EntityManager em = emf.createEntityManager();
		em.getTransaction().begin();
		ManyCustomer cpk = new ManyCustomer();
		ManyAddress addr1 = new ManyAddress();
		ManyAddress addr2 = new ManyAddress();
		cpk.setName("zdc");
		addr1.setAddr("123456");
		addr2.setAddr("789012");
		addr1.setCustomer(cpk);
		addr2.setCustomer(cpk);
		em.persist(addr1);
		em.persist(addr2);
		em.getTransaction().commit();
		em.close();
		emf.close(); 
	}

}
